﻿//Created by Action Script Viewer - http://www.buraks.com/asv
package Classes.util {

    public class DateFormatter {

        public static const CENTRAL_EUROPEAN:String = "CET";
        public static const EASTERN_EUROPEAN:String = "EET";
        public static const BAGHDAD:String = "BT";
        public static const CHINA_COST:String = "CCT";
        public static const JAPAN_STANDARD:String = "JST";
        public static const GUAM_STANDARD:String = "GT";
        public static const NEW_ZEALAND:String = "NZST";
        public static const WEST_AFRICA:String = "WAT";
        public static const AZORES:String = "AT";
        public static const ATLANTIC_STANDARD:String = "AST";
        public static const EASTERN_DAYLIGHT:String = "EDT";
        public static const CENTRAL_DAYLIGHT:String = "CDT";
        public static const MOUNTAIN_DAYLIGHT:String = "MDT";
        public static const PACIFIC_DAYLIGHT:String = "PDT";
        public static const EASTERN_STANDARD:String = "EST";
        public static const CENTRAL_STANDARD:String = "CST";
        public static const MOUNTAIN_STANDARD:String = "MST";
        public static const PACIFIC_STANDARD:String = "PST";
        public static const YUKON_STANDARD:String = "YST";
        public static const ALASKA_HAWAII:String = "HST";
        public static const NOME_TIME:String = "NT";
        public static const DATE_LINE_WEST:String = "IDLW";
        private static const CET:String = "+0100";
        private static const EET:String = "+0200";
        private static const BT:String = "+0300";
        private static const CCT:String = "+0800";
        private static const JST:String = "+0900";
        private static const GT:String = "+1000";
        private static const NZST:String = "+1200";
        private static const WAT:String = "-0100";
        private static const AT:String = "-0200";
        private static const AST:String = "-0400";
        private static const EDT:String = "-0400";
        private static const CDT:String = "-0500";
        private static const MDT:String = "-0600";
        private static const PDT:String = "-0700";
        private static const EST:String = "-0500";
        private static const CST:String = "-0600";
        private static const MST:String = "-0700";
        private static const PST:String = "-0800";
        private static const YST:String = "-0900";
        private static const HST:String = "-1000";
        private static const NT:String = "-1100";
        private static const IDLW:String = "-1200";

        public static function parseDateString(_arg1:String):Date{
            if (((!(_arg1)) || ((_arg1 == "")))){
                return (null);
            };
            var _local2:String = new String(convertTimeZone(_arg1));
            var _local3:Number = Date.parse(_local2);
            var _local4:Date = new Date(_local3);
            return (_local4);
        }
        public static function parseTimeString(_arg1:String):Number{
            if (((!(_arg1)) || ((_arg1 == "")))){
                return (NaN);
            };
            var _local2:String = new String(convertTimeZone(_arg1));
            var _local3:Number = Date.parse(_local2);
            return (_local3);
        }
        public static function convertTimeZone(_arg1:String):String{
            if (((!(_arg1)) || ((_arg1 == "")))){
                return (_arg1);
            };
            if (_arg1.search(/GMT/ig) >= 0){
                return (_arg1);
            };
            if (_arg1.search(/UTC/ig) >= 0){
                return (_arg1);
            };
            _arg1 = _arg1.replace(CENTRAL_EUROPEAN, ("GMT" + CET));
            _arg1 = _arg1.replace(EASTERN_EUROPEAN, ("GMT" + EET));
            _arg1 = _arg1.replace(BAGHDAD, ("GMT" + BT));
            _arg1 = _arg1.replace(CHINA_COST, ("GMT" + CCT));
            _arg1 = _arg1.replace(JAPAN_STANDARD, ("GMT" + JST));
            _arg1 = _arg1.replace(GUAM_STANDARD, ("GMT" + GT));
            _arg1 = _arg1.replace(NEW_ZEALAND, ("GMT" + NZST));
            _arg1 = _arg1.replace(WEST_AFRICA, ("GMT" + WAT));
            _arg1 = _arg1.replace(AZORES, ("GMT" + AT));
            _arg1 = _arg1.replace(ATLANTIC_STANDARD, ("GMT" + AST));
            _arg1 = _arg1.replace(EASTERN_DAYLIGHT, ("GMT" + EDT));
            _arg1 = _arg1.replace(CENTRAL_DAYLIGHT, ("GMT" + CDT));
            _arg1 = _arg1.replace(MOUNTAIN_DAYLIGHT, ("GMT" + MDT));
            _arg1 = _arg1.replace(PACIFIC_DAYLIGHT, ("GMT" + PDT));
            _arg1 = _arg1.replace(EASTERN_STANDARD, ("GMT" + EST));
            _arg1 = _arg1.replace(CENTRAL_STANDARD, ("GMT" + CST));
            _arg1 = _arg1.replace(MOUNTAIN_STANDARD, ("GMT" + MST));
            _arg1 = _arg1.replace(PACIFIC_STANDARD, ("GMT" + PST));
            _arg1 = _arg1.replace(YUKON_STANDARD, ("GMT" + YST));
            _arg1 = _arg1.replace(ALASKA_HAWAII, ("GMT" + HST));
            _arg1 = _arg1.replace(NOME_TIME, ("GMT" + NT));
            _arg1 = _arg1.replace(DATE_LINE_WEST, ("GMT" + IDLW));
            return (_arg1);
        }

    }
}//package Classes.util 
